`include "ysyx_23060189_cpu.svh"
`include "ysyx_23060189_isa.svh"

`ifndef __ysyx_23060189_DECODE_HEADER__
  `define __ysyx_23060189_DECODE_HEADER__

  `define ysyx_23060189_CTRL_SIGNAL_LENGTH 27
  `define ysyx_23060189_CtrlSignalBus      26:0

  //         PC_sel                 Imm_sel                 Alu_op
//         st_type                ld_type                 br_type
  //         A_sel                  B_sel                   wb_sel
  //         csr_cmd               wb_en

  `define ysyx_23060189_DEFAULT_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_XXX,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_X,  `ysyx_23060189_ALU_SEL_X, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b0}

  `define ysyx_23060189_LUI_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_U,     `ysyx_23060189_ALU_CP_B,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_PC, `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_AUIPC_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_U,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_PC, `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_JAL_DECODE \
  {`ysyx_23060189_PC_ALU,     `ysyx_23060189_IMM_J,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_PC, `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_PC_4,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_JALR_DECODE \
  {`ysyx_23060189_PC_ALU,     `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_PC_4,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_BEQ_DECODE \
  {`ysyx_23060189_PC_4,     `ysyx_23060189_IMM_B,       `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_BEQ,\
   `ysyx_23060189_ALU_SEL_PC,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b0}

  `define ysyx_23060189_BNE_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_B,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_BNE,\
   `ysyx_23060189_ALU_SEL_PC, `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b0}

  `define ysyx_23060189_BLT_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_B,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_BLT,\
   `ysyx_23060189_ALU_SEL_PC, `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b0}

  `define ysyx_23060189_BGE_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_B,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_BGE,\
   `ysyx_23060189_ALU_SEL_PC, `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b0}

  `define ysyx_23060189_BLTU_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_B,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_BLTU,\
   `ysyx_23060189_ALU_SEL_PC, `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b0}

  `define ysyx_23060189_BGEU_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_B,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_BGEU,\
   `ysyx_23060189_ALU_SEL_PC, `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b0}

  `define ysyx_23060189_LB_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_LB,     `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_MEM,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_LH_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_LH,     `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_MEM,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_LW_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_LW,     `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_MEM,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_LBU_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_LBU,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_MEM,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_LHU_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_LHU,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_MEM,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SB_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_S,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_SB,      `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b0}

  `define ysyx_23060189_SH_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_S,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_SH,      `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b0}

  `define ysyx_23060189_SW_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_S,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_SW,      `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b0}

  `define ysyx_23060189_ADDI_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SLTI_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_SLT,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SLTIU_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_SLTU,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_XORI_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_XOR,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_ORI_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_OR,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SLLI_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_SL,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SRLI_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_SRL,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SRAI_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_SRA,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_ADD_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_ADD,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_R, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SUB_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_SUB,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_R, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SLL_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_SL,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_R, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SLT_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_SLT,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_R, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SLTU_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_SLTU,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_R, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_ANDI_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_I,     `ysyx_23060189_ALU_AND,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_I, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_XOR_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_XOR,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_R, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SRL_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_SRL,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_R, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_SRA_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_SRA,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_R, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_OR_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_OR,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_R, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_AND_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_AND,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_R, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_N,      1'b1}

  `define ysyx_23060189_CSRRW_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_CP_A,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_X, `ysyx_23060189_WB_SEL_CSR,\
   `ysyx_23060189_CSR_W,      1'b1}

  `define ysyx_23060189_CSRRS_DECODE \
  {`ysyx_23060189_PC_4,       `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_CP_A,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_R,  `ysyx_23060189_ALU_SEL_X, `ysyx_23060189_WB_SEL_CSR,\
   `ysyx_23060189_CSR_S,      1'b1}

  `define ysyx_23060189_ECALL_DECODE \
  {`ysyx_23060189_PC_CSR,     `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_XXX,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_X,  `ysyx_23060189_ALU_SEL_X, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_P,      1'b0}

  `define ysyx_23060189_MRET_DECODE \
  {`ysyx_23060189_PC_CSR,     `ysyx_23060189_IMM_X,     `ysyx_23060189_ALU_XXX,\
   `ysyx_23060189_ST_XXX,     `ysyx_23060189_LD_XXX,    `ysyx_23060189_BR_XXX,\
   `ysyx_23060189_ALU_SEL_X,  `ysyx_23060189_ALU_SEL_X, `ysyx_23060189_WB_SEL_ALU,\
   `ysyx_23060189_CSR_P,      1'b0}

`endif
